package com.ruoyi.prevention.isoward.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.prevention.isoward.domain.Isoward;
import com.ruoyi.prevention.isoward.service.IIsowardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 隔离病房信息Controller
 * 
 * @author wad
 * @date 2022-04-06
 */
@RestController
@RequestMapping("/prevention/isoward")
public class IsowardController extends BaseController
{
    @Autowired
    private IIsowardService isowardService;

    /**
     * 查询隔离病房信息列表
     */
    @PreAuthorize("@ss.hasPermi('prevention:isoward:list')")
    @GetMapping("/list")
    public TableDataInfo list(Isoward isoward)
    {
        startPage();
        List<Isoward> list = isowardService.selectIsowardList(isoward);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('prevention:isoward:list')")
    @GetMapping("/isowardlist")
    public List<Isoward> isolist(Isoward isoward)
    {
        List<Isoward> list = isowardService.selectIsowardList(isoward);
        return list;
    }

    /**
     * 导出隔离病房信息列表
     */
    @PreAuthorize("@ss.hasPermi('prevention:isoward:export')")
    @Log(title = "隔离病房信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Isoward isoward)
    {
        List<Isoward> list = isowardService.selectIsowardList(isoward);
        ExcelUtil<Isoward> util = new ExcelUtil<Isoward>(Isoward.class);
        util.exportExcel(response, list, "隔离病房信息数据");
    }

    /**
     * 获取隔离病房信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('prevention:isoward:query')")
    @GetMapping(value = "/{wardId}")
    public AjaxResult getInfo(@PathVariable("wardId") Long wardId)
    {
        return AjaxResult.success(isowardService.selectIsowardByWardId(wardId));
    }

    /**
     * 新增隔离病房信息
     */
    @PreAuthorize("@ss.hasPermi('prevention:isoward:add')")
    @Log(title = "隔离病房信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Isoward isoward)
    {
        return toAjax(isowardService.insertIsoward(isoward));
    }

    /**
     * 修改隔离病房信息
     */
    @PreAuthorize("@ss.hasPermi('prevention:isoward:edit')")
    @Log(title = "隔离病房信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Isoward isoward)
    {
        return toAjax(isowardService.updateIsoward(isoward));
    }

    /**
     * 删除隔离病房信息
     */
    @PreAuthorize("@ss.hasPermi('prevention:isoward:remove')")
    @Log(title = "隔离病房信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wardIds}")
    public AjaxResult remove(@PathVariable Long[] wardIds)
    {
        return toAjax(isowardService.deleteIsowardByWardIds(wardIds));
    }
}
